package com.cn.redis.dto;

import java.util.Arrays;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;

public class c {
    private String key;
    private b[] i = new b[]{new b(this), new b(this)};
    private volatile int j = 0;
    private volatile boolean k = false;
    private volatile boolean l = false;
    private final AtomicBoolean m = new AtomicBoolean(false);
    private final ReadWriteLock n = new ReentrantReadWriteLock();
    private volatile int step;
    private volatile int o;
    private volatile long p;

    public c() {
    }

    public String getKey() {
        return this.key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public b[] g() {
        return this.i;
    }

    public b h() {
        return this.i[this.j];
    }

    public int getCurrentPos() {
        return this.j;
    }

    public int i() {
        return (this.j + 1) % 2;
    }

    public void j() {
        this.j = this.i();
    }

    public boolean k() {
        return this.l;
    }

    public void a(boolean initOk) {
        this.l = initOk;
    }

    public boolean l() {
        return this.k;
    }

    public void b(boolean nextReady) {
        this.k = nextReady;
    }

    public AtomicBoolean m() {
        return this.m;
    }

    public Lock n() {
        return this.n.readLock();
    }

    public Lock o() {
        return this.n.writeLock();
    }

    public int getStep() {
        return this.step;
    }

    public void setStep(int step) {
        this.step = step;
    }

    public int p() {
        return this.o;
    }

    public void b(int minStep) {
        this.o = minStep;
    }

    public long q() {
        return this.p;
    }

    public void c(long updateTimestamp) {
        this.p = updateTimestamp;
    }

    public String toString() {
        StringBuilder sb = new StringBuilder("SegmentBuffer{");
        sb.append("key='").append(this.key).append('\'');
        sb.append(", segments=").append(Arrays.toString(this.i));
        sb.append(", currentPos=").append(this.j);
        sb.append(", nextReady=").append(this.k);
        sb.append(", initOk=").append(this.l);
        sb.append(", threadRunning=").append(this.m);
        sb.append(", step=").append(this.step);
        sb.append(", minStep=").append(this.o);
        sb.append(", updateTimestamp=").append(this.p);
        sb.append('}');
        return sb.toString();
    }
}
